package com.wxzz.elearing.comment.api.server;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wxzz.elearing.comment.dto.OrderIdDto;
import com.wxzz.elearing.comment.entity.QuestionsAnswersList;
import com.wxzz.elearing.comment.mapper.QuestionsAnswersListMapper;
import com.wxzz.elearing.comment.service.ICommentService;
import com.wxzz.elearing.comment.service.IQuestionsAnswersListService;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/wxqwpay-api")
public class WxQwPayApi {

    @Autowired
    private IQuestionsAnswersListService iQuestionsAnswersListService;

    @Resource
    private QuestionsAnswersListMapper questionsAnswersListMapper;

    @ApiOperation(value = "改变支付状态", notes = "改变支付状态", httpMethod = "POST", tags = "小程序")
    @RequestMapping(value = "/isPayChange/{orderId}", method = RequestMethod.POST)
    public ReturnVO iQuestionsAnswersListService(@PathVariable(value = "orderId") Long orderId) {
        questionsAnswersListMapper.updateIsPay(orderId);
        return new ReturnVO("支付成功，问答已发布", null);
    }

    @Autowired
    private ICommentService commentService;

    /**
     * 根据订单id查询目标用户id
     *
     * @return
     */
    //@ApiOperation(value = "根据订单id查询目标用户id", notes = "根据订单id查询目标用户id", httpMethod = "POST", tags = "小程序")
    @RequestMapping(value = "userIdByOrderId/{orderId}", method = RequestMethod.POST)
    public ReturnVO getUserIdByOrderId(@PathVariable Long orderId) {
        return commentService.getUserIdByOrderId(orderId);
    }

}
